// app.js
// 导入工具-全局加载
import './utils/utils'
import './utils/http'
App({
  onLaunch() {
    this.getToken()
  },
  setToken(token, refresh_token) {
    // 拼接token Bearer
    token = 'Bearer ' + token
    refresh_token = 'Bearer ' + refresh_token
    // 本地存储token和refresh_token
    wx.setStorageSync('token', token)
    wx.setStorageSync('refresh_token', refresh_token)
    this.token = token
    this.refresh_token = refresh_token
  },
  getToken() {
    wx.getStorage({
        key: 'token',
        success: ({
          data
        }) => {
          // this 指向应用实例
          this.token = data
        },
        fail() {},
      }),
      wx.getStorage({
        key: 'refresh_token',
        success: ({
          data
        }) => {
          // this 指向应用实例
          this.refresh_token = data
        },
        fail() {},
      }),
      wx.getStorage({
        key: 'userInfo',
        success: ({
          data
        }) => {
          // this 指向应用实例
          this.userInfo = data
        },
        fail() {},
      })
  }
})